package com.zerox.service.impl;

import com.zerox.entity.SysMenu;
import com.zerox.mapper.SysMenuMapper;
import com.zerox.service.SysMenuService;
import com.zerox.uilt.MenuVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

@Service
public class SysMenuServiceImpl implements SysMenuService {

    @Autowired
    private SysMenuMapper sysMenuMapper;

    @Override
    public SysMenu selectByParentId(int parentId) {
        return null;
    }

    @Override
    public List<SysMenu> info() {
        return null;
    }

    @Override
    public List<MenuVO> menupates(String username) {
        return sysMenuMapper.menupates(username);
    }

    @Override
    public List<MenuVO> menuchilds(String username) {
        return sysMenuMapper.menuchilds(username);
    }

    @Override
    public List<SysMenu> list(String menuName, Integer startIndex, Integer pageSize) {
        if(Objects.isNull(startIndex)){
            startIndex = 1;
        }
        if(Objects.isNull(pageSize)){
            pageSize = 10;
        }
        int pageIndex = (startIndex-1)*pageSize;

        return sysMenuMapper.list(menuName,pageIndex,pageSize);
    }

    @Override
    public int add(SysMenu sysMenu) {
        return sysMenuMapper.add(sysMenu);
    }

    @Override
    public int delete(Integer menuId) {
        return sysMenuMapper.delete(menuId);
    }

    @Override
    public SysMenu selectById(Integer menuId) {
        return sysMenuMapper.menuById(menuId);
    }

    @Override
    public int update(SysMenu sysMenu) {
        return sysMenuMapper.update(sysMenu);
    }

    @Override
    public List<MenuVO> parents() {
        return null;
    }

    @Override
    public int count(String menuName) {
        return sysMenuMapper.count(menuName);
    }


}

